// index.js
// 获取应用实例
const app = getApp()
import {
  getAaActiveDetailPage,
  getAaActiveDetailPhotoPage,
} from "../../../api/activity.js";
Page({
  data: {
    index: 0,
    num: '',
    camp: "",
    latitude: 29.539852, //纬度
    longitude: 106.565742, //经度
    makers: [{
      iconPath: '/images/定位.png',
      id: 0,
      latitude: 29.539852,
      longitude: 106.565742,
      width: 50,
      height: 50
    }],
    swiperList: [{
      id: 0,
      type: 'image',
      photoUrl: '/images/图片/2.jpg'
    }, ],
    imgDetail: [{
      photoUrl: '/images/图片/2.jpg'
    }],
  },
  makertap: function () {
    let _this = this
    wx.getLocation({
      type: 'wgs84',
      success(res) {
        // console.log(res);
        const latitude = res.latitude
        const longitude = res.longitude
        const speed = res.speed
        const accuracy = res.accuracy
        _this.setData({
          latitude: latitude,
          longitude: longitude
        })
      }
    })
  },
  buttonTap: function () {
    wx.getLocation({
      type: 'gcj02',
      success: function (res) {
        wx.openLocation({
          latitude: res.latitude,
          longitude: res.longitude
        })
      }
    })
  },

  onChange(e) {
    const {
      index
    } = e.detail;

    // console.log(index);
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  go: function () {
    let id=this.data.camp.id
    console.log(id)
   id = JSON.stringify(id)
    wx.navigateTo({
      url: '../../index/goods_detail/goods_detail?id=' + id
    })
  },

  onLoad(options) {
    let id = JSON.parse(options.id)
    // console.log(id);
    this.getAaActiveDetailPhotoPage(id)
    this.getAaActiveDetailPage(id)
    this.makertap()

  },
  getAaActiveDetailPhotoPage(id) {
    let data = {
      "pageNum": "1",
      "pageSize": "10",
      "id": id,
      "aaActiveDetailId": null,
      "photoUrl": null,
      "status": null,
      "delFlag": null,
      "createBy": null,
      "createTime": null,
      "updateBy": null,
      "updateTime": null,
      "remark": null
    }
    getAaActiveDetailPhotoPage(data).then(res => {
      let datalist = res.data.data.records
      console.log(datalist)
      this.setData({
        swiperList: datalist,
        imgDetail: datalist
      })
    })
  },
  getAaActiveDetailPage(id) {
    let data = {
      "pageNum": "1",
      "pageSize": "10",
      "id": null,
      "aaActiveId": id,
      "gameplayType": null,
      "detailText": null,
      "status": null,
      "delFlag": null,
      "createBy": null,
      "createTime": null,
      "updateBy": null,
      "updateTime": null,
      "remark": null
    }
    getAaActiveDetailPage(data).then(res => {
      let camp = res.data.data.records[0].aaActive;
      console.log(camp)
      camp.latitude = '29.678534618042985'
      camp.longitude = '116.01511473945618'
      this.setData({
        camp: camp,
      })
    })
  },

  jumpPage() {

  },

})